package com.example.f_code;

import android.app.Application;

import androidx.room.Room;

import com.example.f_code.db.bean.UserDatabase;

public class MyApplication extends Application {
    private static MyApplication instance;
    private UserDatabase userDatabase;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        userDatabase = Room.databaseBuilder(this, UserDatabase.class, "user_database")
                .allowMainThreadQueries() // 允许在主线程中执行数据库查询
                .build();
    }

    public static MyApplication getInstance() {
        if (instance == null) {
            instance = new MyApplication();
        }
        return instance;
    }

    public UserDatabase getUserDatabase() {
        return userDatabase;
    }
}
